//
//  UIBarButtonItem+Extension.m
//  AMwb
//
//  Created by zhc on 15/11/28.
//  Copyright © 2015年 zhc. All rights reserved.
//

#import "UIBarButtonItem+Extension.h"

@implementation UIBarButtonItem (Extension)

+ (UIBarButtonItem *)itemWithtager:(id)tager image:(NSString *)image imageHighlighted:(NSString *)imageHlightlighted action:(SEL)action
{
    
    
    UIButton *btn=[UIButton buttonWithType:UIButtonTypeCustom];
    
    [btn setBackgroundImage:[UIImage imageNamed:image] forState:UIControlStateNormal];
    
    [btn setBackgroundImage:[UIImage imageNamed:imageHlightlighted] forState:UIControlStateHighlighted];
    
    
    CGSize sizeMore=btn.currentBackgroundImage.size;
    
    btn.frame=CGRectMake(0, 0, sizeMore.width, sizeMore.height);
    
    [btn addTarget:tager action:action forControlEvents:UIControlEventTouchUpInside];
    
    return [[UIBarButtonItem alloc]initWithCustomView:btn];
    
    
}


@end
